-- RemoteAttackAction
-- create by cheny3
-- 远程怪攻击动作

RemoteAttackAction = class("RemoteAttackAction", function()
    return ActionBase.create();
end);
function RemoteAttackAction.create(source, target, skillId)
    local self = RemoteAttackAction.new();
    self.source = source;
    self.target = target;
    self.skillId = skillId;
    return self;
end

-- 构造函数
function RemoteAttackAction:ctor()
end

-- 开始播放
function RemoteAttackAction:play()
    local delay = 0;

    if self.source.type == OBJECT_TYPE_MONSTER then
        -- 怪物攻击动作
        delay = self:monsterAttackAction();
    end

    return delay;
end

-- 怪物攻击玩家
function RemoteAttackAction:monsterAttackAction()
    local delay = 2;
    local skillId = self.skillId;

    if type(skillId) == "number" and skillId > 0 then
        local monsterDisplay = MonsterDisplayM.getMonsterSkillDisplay(self.source:getClassId(), skillId);

        if monsterDisplay and #table.keys(monsterDisplay) > 0 then
            delay = monsterDisplay.delay;
        end
    end

    -- 抛出远程怪攻击事件
    EventMgr.fire(event.REMOTE_ATTACK, {["pos"] = self.source:getOwner(), ["skillId"] = self.skillId, });

    -- 怪物攻击动作，后续操作不需要等待
    return 0;
end

return RemoteAttackAction;